package cn.edu.sziit.bbs.service;

import cn.edu.sziit.bbs.dao.ReplyMapper;
import cn.edu.sziit.bbs.model.Reply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReplyService {

    @Autowired
    private ReplyMapper replyMapper;

    /**
     * 根据postId查询回复
     *
     * @param postId
     * @return
     */
    public List<Reply> selectByPostId(Integer postId) {
        return replyMapper.selectByPostId(postId);
    }

    /**
     * 插入回复
     *
     * @param reply
     */
    public void insert(Reply reply) {

        replyMapper.insertSelective(reply);
    }

    /**
     * 根据replyId删除回复
     *
     * @param replyId
     * @return
     */
    public String deleteByPrimaryKey(Integer replyId) {
        replyMapper.deleteByPrimaryKey(replyId);
        return "删除评论成功";
    }

    /**
     * 根据userId查询reply
     *
     * @param userId
     * @return
     */
    public List<Reply> selectAllByUserId(Integer userId) {
        return replyMapper.selectAllByUserId(userId);
    }

    /**
     * 根据replyContent模糊查询reply
     *
     * @param replyContent
     * @return
     */
    public List<Reply> selectAllByReplyContent(String replyContent) {
        return replyMapper.selectAllByReplyContent(replyContent);
    }

}
